<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Body
 *
 * @author julien
 */
require_once 'Classes/View/ViewItems/ViewElement.php';
require_once 'Classes/View/ViewItems/TextFieldItem.php';

class Body extends ViewElement{
    
    private $content;
    
    public function __construct($pageElement=null) {
        $content = array();
        $this->addContent($pageElement);
    }
    
    public function addContent($pageElement){
         if(! is_null($pageElement) && is_object($pageElement) && get_parent_class($pageElement) == "ViewElement"){
            $this->content[count($this->content)] = $pageElement;
        }
         else if(is_array($pageElement)){
            foreach ($pageElement as $key => $value) {
                $this->addContent($value);
            }
        }
        else {
            $this->content[count($this->content)] = new TextFieldItem($pageElement);
        }
    }
    public function getHTML() {
        $return  = "";
        $return .= '<body>'."\n";
        foreach($this->content as $element){
            $return .= $element->getHTML();
        }
        $return .= '</body>';
        
        return $return;
    }
}

?>
